﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ToWaDBFirst.Models;

namespace ToWaDBFirst.Controllers
{
    /**
     * Controller to handle information on the /Home/ screen.
     **/
    [Authorize]
    public class HomeController : Controller
    {

        /**
         * Class object to handle service operations.
         **/
        ToWaService service = new ToWaService();
        
        /**
         * Method to handle requests to the Index page and redirect to the Index View (/Home/Index).
         **/
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome " + User.Identity.Name;
            ViewBag.lastVisit = service.LastLogin(User.Identity.Name);
            ViewBag.amount = service.NumberOfLoginsInDays(30, User.Identity.Name);
            ViewBag.unread = service.UnreadMessages(User.Identity.Name);

            return View();
        }

        /**
         * method to handle requests to the About page and redirect (/Home/About).
         **/
        public ActionResult About()
        {
            return View();
        }
    }
}
